//
//  VisitorTableViewController.swift
//  weibo
//
//  Created by 陈伟 on 15/10/16.
//  Copyright © 2015年 陈伟. All rights reserved.
//

import UIKit
import SDWebImage

class VisitorTableViewController: UITableViewController {
    
    private var userLogin = UserAccountViewModel.sharedUserAccount.userLogin
//    private var userLogin = false
    
    var visitorView: VisitorView?
    
    @objc private func registerBtnClick() {
        print("别注册")
    }
    
    @objc private func loginBtnClick() {
        print("想登录？")
        let vc = OAuthViewController()
        let nav = UINavigationController(rootViewController: vc)
        presentViewController(nav, animated: true, completion: nil)
    }
    
    //判断是否登录来显示
    override func loadView() {
        
        userLogin ? super.loadView() : setupVisitorView()
    }
    
    private func setupVisitorView() {
        visitorView = VisitorView()
        
        view = visitorView
        
        visitorView?.registerButton.addTarget(self, action: "registerBtnClick", forControlEvents: UIControlEvents.TouchUpInside)
        visitorView?.loginButton.addTarget(self, action: "loginBtnClick", forControlEvents: UIControlEvents.TouchUpInside)
    }
}

